<?php
session_start();
require_once '../header.php';
function __autoload($className)
	{
    	require_once('../class/' . $className . '.class.php');
	}
session::need_manage();
if(!empty($_POST))
{
	$ArrPost=$_POST;
	$CcNumPost=intval($ArrPost["ccnumpos"])-1;
	$CcExmonthPost=intval($ArrPost["exmonthpost"])-1;
	$CcExYearPost=intval($ArrPost["exyearpos"])-1;
	$CcvPost=intval($ArrPost["ccvpos"])-1;
	$SoureCc=explode("\n",$_POST["sourecc"]);
	$Price=$ArrPost['price'];
	if(!empty($Price))
	{
	foreach($SoureCc as $CcInfo)
	{
		
		$Cc=rtrim(trim($CcInfo));
		if($Cc !=null)
		{
			$ArrCcInfo=explode("|",$Cc);
			$CcNums=rtrim(trim($ArrCcInfo["$CcNumPost"]));
			$CcExMonth=rtrim(trim($ArrCcInfo["$CcExmonthPost"]));
			$CcExYear=rtrim(trim($ArrCcInfo["$CcExYearPost"]));
			$Ccv=rtrim(trim($ArrCcInfo["$CcvPost"]));
			$CCNumHash=hash::hashccv($CcNums, $CcExMonth, $CcExYear, $Ccv);
			$Update=database::Update('ccinfo',array(
			'ccnumber' => $CCNumHash
			),array(
			'userid' => 0,
			'timeorder' => NULL,
			'orderid' => 0,
			'price' => $Price,
			'status' => 'nottest'
			));
			if($Update==1)
			{
				
				$_SESSION["erro"]="Đã Update lại cc này";
				redirect::location("../admincp.php");
			}
		}
		
		
	}
	}
	else 
	{
		?>
		<script type="text/javascript" >
		alert("Chưa Điền Price" );
		</script>
		<?php 
	}
}
else 
{
	$webroot="../";
	require_once '../html/addoldcc.php';
}

?>